#include <iostream>
#include <thread>
#include <mutex>
using std::cout;
using std::endl;
using std::thread;
using std::mutex;

int count = 0;
mutex mtx;
#if 0
void add(){
    for(int i = 0;i < 10000;++i){
        mtx.lock();
        count++;
        mtx.unlock();
    }
}
#endif

#if 0
void add2(){
    for(int i = 0;i < 10000;++i){
        {
            std::lock_guard<mutex> lg(mtx);
            count++;
        }
    }
}
#endif


void add3(){
    for(int i = 0;i < 10000;++i){
        std::unique_lock<mutex> ul(mtx);
        //ul.lock();
        count++;
        ul.unlock();
    }
}

int main()
{
    
    thread th1(add3);
    thread th2(add3);
    th1.join();
    th2.join();
    cout << count << endl;
    return 0;
}

